<template>
  <div class="xgmm">
    <van-nav-bar title="修改密码" left-arrow @click-left="$router.back()" />


     <van-form @submit="onSubmit" ref="regForm">

      
      <van-field
        left-icon="gem"
        v-model="oldPassword"
        type="password"
        name="oldPassword"
        label="旧密码"
        placeholder="旧密码"
        :rules="[
          { required: true, message: '请输入密码' },
          {
            validator: (e) => /^\w{6,12}$/.test(e),
            message: '密码格式为6-12位字母或数字',
          },
        ]"
      />
      <van-field
        left-icon="gem"
        v-model="newPassword"
        type="password"
        name="newPassword"
        label="新密码"
        placeholder="新密码"
        :rules="[
          { required: true, message: '请输入密码' },
          {
            validator: (e) => /^\w{6,12}$/.test(e),
            message: '密码格式为6-12位字母或数字',
          },
        ]"
      />
      <van-button
        color="#4fc08d"
        block
        native-type="submit"
        :loading="submitLoading"
        >确定重置</van-button
      >
    </van-form>
  </div>
</template>

<script>
import {xgai} from "@/api/xgmm";
export default {
name: "wjmm",
data(){
    return{
        newPassword: "",
      oldPassword: "",
      submitLoading: false,
    }
},
methods:{
     onSubmit(values) {
      console.log("submit", values);
      this.submitLoading = true;
      xgai(values)
        .then((res) => {
          console.log(res);
        })
        .finally((e) => {
          this.submitLoading = false;
        });
    },
}
}
</script>

<style>

</style>